﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using CSharpDesign.DAL;
using CSharpDesign.BLL;

namespace CSharpDesign.Admin
{
    public partial class AddAdmin : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {


        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                AddAdminService aas = new AddAdminService();
                SqlConnection con = new SqlConnection(SqlHelper.connstring);
                con.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = (SqlConnection)con;//对象实例化
                string pwd = this.txtpwd.Text;
                string name = this.txtname.Text;
                aas.AddAdmin(cmd,pwd, name);
                cmd.ExecuteNonQuery();
                con.Close();
                Response.Write("<script language='javascript'>alert('添加成功');location.href='AdminList.aspx'</script>");
            }
            catch
            {
                Response.Write("<script language='javascript'>alert('添加失败');location.href='AdminList.aspx'</script>");
            }
        }
    }

}